import 'package:flutter/material.dart';
import 'package:my_app/components/a_button/index.dart';
import 'package:my_app/uitls/custom_appbar.dart';
import 'package:my_app/uitls/icon.dart';

class ExampleAButton extends StatefulWidget {
  ExampleAButton({super.key});

  @override
  State<ExampleAButton> createState() => _ExampleAButtonState();
}

class _ExampleAButtonState extends State<ExampleAButton> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: customAppBar(
        title: 'AButton Component',
        context: context,
      ),
      body: SafeArea(
        child: SingleChildScrollView(
          padding: EdgeInsets.symmetric(horizontal: 15, vertical: 15),
          child: Column(
            children: [
              Row(children: [Text('按钮类型')]),
              Container(
                margin: EdgeInsets.symmetric(vertical: 15),
                child: Row(
                  children: [
                    space(
                        AButton.normal(child: Text('默认按钮'), onPressed: () {})),
                    space(AButton.normal(
                        child: Text('主要按钮'),
                        type: 'primary',
                        onPressed: () {})),
                    space(AButton.normal(
                        child: Text('信息按钮'), type: 'info', onPressed: () {})),
                  ],
                ),
              ),
              Container(
                margin: EdgeInsets.symmetric(vertical: 10),
                child: Row(
                  children: [
                    space(AButton.normal(
                        child: Text('危险按钮'), type: 'danger', onPressed: () {})),
                    space(AButton.normal(
                        child: Text('警告按钮'), type: 'warning', onPressed: () {}))
                  ],
                ),
              ),
              Row(children: [Text('禁用状态')]),
              Container(
                margin: EdgeInsets.symmetric(vertical: 10),
                child: Row(
                  children: [
                    space(AButton.normal(child: Text('主要按钮'), type: 'primary')),
                    space(AButton.normal(child: Text('警告按钮'), type: 'warning'))
                  ],
                ),
              ),
              Row(children: [Text('边框按钮')]),
              Container(
                margin: EdgeInsets.symmetric(vertical: 10),
                child: Row(
                  children: [
                    space(AButton.normal(
                        child: Text('危险按钮'),
                        type: 'danger',
                        plain: true,
                        onPressed: () {})),
                    space(AButton.normal(
                        child: Text('警告按钮'),
                        type: 'warning',
                        plain: true,
                        onPressed: () {}))
                  ],
                ),
              ),
              Row(children: [Text('icon按钮')]),
              Container(
                margin: EdgeInsets.symmetric(vertical: 10),
                child: Row(
                  children: [
                    space(AButton.icon(
                        width: 44,
                        icon: icongouwuche(),
                        type: 'primary',
                        onPressed: () {})),
                    space(AButton.icon(
                        width: 44,
                        icon: icongouwuche(),
                        type: 'primary',
                        plain: true,
                        onPressed: () {})),
                    space(AButton.icon(
                        textChild: Text('按钮'),
                        icon: icongouwuche(),
                        type: 'primary',
                        plain: true,
                        onPressed: () {})),
                  ],
                ),
              ),
              Row(children: [Text('圆角按钮')]),
              Container(
                margin: EdgeInsets.symmetric(vertical: 10),
                child: Row(
                  children: [
                    space(AButton.icon(
                        borderRadius: BorderRadius.circular(40),
                        width: 44,
                        icon: icongouwuche(),
                        type: 'primary',
                        onPressed: () {})),
                    space(AButton.icon(
                        plain: true,
                        borderRadius: BorderRadius.circular(40),
                        width: 44,
                        icon: icongouwuche(),
                        type: 'primary',
                        onPressed: () {})),
                    space(AButton.normal(
                        width: 80,
                        height: 30,
                        bgColor: Color.fromRGBO(204, 192, 180, 1),
                        type: 'primary',
                        borderRadius: BorderRadius.circular(44),
                        onPressed: () {},
                        child: Text('冰'))),
                    space(AButton.normal(
                        width: 80,
                        height: 30,
                        plain: true,
                        bgColor: Color.fromRGBO(204, 192, 180, 1),
                        borderRadius: BorderRadius.circular(44),
                        onPressed: () {},
                        child: Text('热',
                            style: TextStyle(
                                color: Color.fromRGBO(204, 192, 180, 1))))),
                  ],
                ),
              ),
              Row(children: [Text('加载按钮')]),
              Container(
                margin: EdgeInsets.symmetric(vertical: 10),
                child: Row(
                  children: [
                    space(AButton.loading(
                        width: 44, type: 'primary', onPressed: () {})),
                    space(AButton.loading(
                        width: 44,
                        type: 'primary',
                        plain: true,
                        onPressed: () {})),
                  ],
                ),
              ),
              Row(children: [Text('自定义按钮')]),
              Container(
                margin: EdgeInsets.symmetric(vertical: 10),
                child: Row(
                  children: [
                    space(AButton.icon(
                        width: 82, 
                        height: 32,
                        bgColor: Color.fromRGBO(136, 175, 213, 0.3),
                        textChild: Text(
                          '收藏口味',
                          style: TextStyle(
                            color: Color.fromRGBO(136, 175, 213, 1),
                            fontSize: 12,
                          ),
                        ),
                        icon: icongouwuche(size: 12, color: Color.fromRGBO(136, 175, 213, 1)),
                        type: 'primary', 
                        onPressed: () {})),
                    space(AButton.icon(
                        width: 82, 
                        height: 32,
                        bgColor: Color.fromRGBO(255, 129, 2, 1),
                        textChild: Text(
                          '冲2赠1',
                          style: TextStyle(
                            color: Color.fromRGBO(255, 255, 255, 1),
                            fontSize: 12,
                          ),
                        ),
                        icon: icongouwuche(size: 12, color: Color.fromRGBO(255, 129, 2, 1)),
                        type: 'primary', 
                        onPressed: () {})),
                    space(AButton.icon(
                        width: 82, 
                        height: 32,
                        borderColor: Colors.blue,
                        bgColor: Color.fromRGBO(255, 129, 2, .1),
                        plain: true,
                        textChild: Text(
                          '冲2赠1',
                          style: TextStyle(
                            color: Colors.blue,
                            fontSize: 12,
                          ),
                        ),
                        icon: icongouwuche(size: 12, color: Color.fromRGBO(255, 129, 2, 1)),
                        onPressed: () {})),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }

  Widget space(Widget child) {
    return Container(
      margin: EdgeInsets.only(right: 20),
      child: child,
    );
  }
}
